// 关闭按钮的下拉
import React, { Component } from 'react';
import { Dropdown, Balloon, Button } from '@teamix/ui';
import { YunxiaoIcon } from '@alife/devops-ui';
import { getFeature } from 'utils/features';

export default class CommentSwitch extends Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
    };
  }

  onOverlayVisibleChange = (visible) => {
    this.setState({
      visible,
    });
  };

  renderDisabledBtn = (disabledMsg) => {
    return (
      <div className="item disabled">
        <Balloon.Tooltip
          align="t"
          trigger={
            <span>
              {getFeature('project.mr.info.default.text').close}
            </span>
          }
        >
          {disabledMsg}
        </Balloon.Tooltip>
      </div>
    );
  };

  render() {
    return (
      <Dropdown
        trigger={
          <Button>
            <YunxiaoIcon type="more-line" />
          </Button>
        }
        triggerType="click"
        align="tr br"
        container={document.querySelector('.mr-title-info')}
        visible={this.state.visible}
        onVisibleChange={this.onOverlayVisibleChange}
      >
        <div className="close-btn-dropdown overlay-shadow">
          <div
            className="item"
            onClick={() => {
              this.props.modifyCr(
                {
                  state_event: 'close',
                },

                () => {
                  // 重新请求日志
                  this.props.getSummaryLogs();
                },
              );
            }}
          >
            {getFeature('project.mr.info.default.text').close}
          </div>
        </div>
      </Dropdown>
    );
  }
}
